﻿<UserControl
    x:Class="Markup.Programming.Samples.TableOfSquares"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:p="http://markupprogramming.codeplex.com/markup/programming"
    Height="300" Width="300">
    <UserControl.Resources>
        <p:ResourceObject x:Key="ViewModel">
            <p:Property PropertyName="Table">
                <p:Iterator>
                    <p:For Var="$i" Value="0" UpperLimit="5" Increment="1">
                        <p:Yield>
                            <p:Object>
                                <p:Property PropertyName="Number" Path="$i"/>
                                <p:Property PropertyName="Square" Path="$i * $i"/>
                                <p:Property PropertyName="Sqrt" Path="[Math].Sqrt($i)"/>
                            </p:Object>
                        </p:Yield>
                    </p:For>
                </p:Iterator>
            </p:Property>
        </p:ResourceObject>
    </UserControl.Resources>
    <Grid DataContext="{StaticResource ViewModel}">
        <StackPanel>
            <ListView ItemsSource="{Binding Table}">
                <ListView.View>
                    <GridView>
                        <GridViewColumn DisplayMemberBinding="{Binding Number}"/>
                        <GridViewColumn DisplayMemberBinding="{Binding Square}"/>
                        <GridViewColumn DisplayMemberBinding="{Binding Sqrt}"/>
                    </GridView>
                </ListView.View>
            </ListView>
            <DataGrid ItemsSource="{Binding Table}"/>
        </StackPanel>
    </Grid>
</UserControl>
